package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.product.ProductBrandPageRequest;
import com.mes.cloud.api.dto.request.product.ProductBrandRequest;
import com.mes.cloud.api.dto.request.product.ProductBrandVoRequest;
import com.mes.cloud.api.dto.request.product.ProductCustomerBrandRequest;
import com.mes.cloud.api.dto.response.product.ProductBrandDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.ProductBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author ysd
 * @email shaodong.yuan@pactera.com
 * @version 2019-08-20 15:48:07
 */
@Api(tags = "产品品牌", value = "产品品牌接口")
@RestController
@RequestMapping(value = "/productBrand")
public class ProductBrandController {

    private ProductBrandService productBrandService;

    @Autowired
    public ProductBrandController(ProductBrandService productBrandService) {
        this.productBrandService = productBrandService;
    }

    /**
     * 功能: 产品品牌分页查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager<ProductBrandDto>>
     */
    @ApiOperation(value = "产品品牌分页查询", notes = "产品品牌分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<ProductBrandDto>> pageList(@Valid @RequestBody ProductBrandPageRequest pageRequest) {
        return productBrandService.pageList(pageRequest);
    }

    /**
     * 功能: 代理能力_关联品牌
     *
     * @param productCustomerBrandRequest
     * @return JsonResult<CommPager<ProductBrandDto>>
     */
    @ApiOperation(value = "代理能力_关联品牌", notes = "代理能力_关联品牌")
    @PostMapping(value = "/findAllCustomerBrand")
    public JsonResult<List<ProductBrandDto>> findAllCustomerBrand(@Valid @RequestBody ProductCustomerBrandRequest productCustomerBrandRequest) {
        return productBrandService.findAllCustomerBrand(productCustomerBrandRequest);
    }

    /**
     * 功能: 产品品牌查询所有
     *
     * @param productBrandRequest
     * @return JsonResult<List<ProductBrandDto>>
     */
    @ApiOperation(value = "产品品牌查询所有", notes = "产品品牌查询所有")
    @PostMapping(value = "/list")
    public JsonResult<List<ProductBrandDto>> list(@RequestBody ProductBrandVoRequest productBrandRequest) {
        return  productBrandService.list(productBrandRequest);
    }

    /**
     * 功能: 产品品牌新增
     *
     * @param productBrandRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品品牌新增", notes = "产品品牌新增")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody ProductBrandRequest productBrandRequest) {
        return productBrandService.add(productBrandRequest);
    }

    /**
     * 功能: 产品品牌修改
     *
     * @param productBrandRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品品牌修改", notes = "产品品牌修改")
    @PostMapping(value = "/update")
    public JsonResult update(@Valid @RequestBody ProductBrandRequest productBrandRequest) {
        return productBrandService.update(productBrandRequest);

    }

    /**
     * 功能: 产品品牌查看详情
     *
     * @param id
     * @return JsonResult
     */
    @ApiOperation(value = "产品品牌查看详情", notes = "产品品牌查看详情")
    @ApiImplicitParam(paramType = "Long", name = "id", value = "产品品牌主键", required = true)
    @GetMapping(value = "get/{id}")
    public JsonResult<ProductBrandDto> get(@PathVariable String id) {
        return productBrandService.get(id);
    }

}
